#pragma once

#include <vector>
#include <boost/function.hpp>

namespace liba {
namespace lib3d {
namespace material {

class TextureFrame;

class TextureLoadingNotifier
{
	friend class TextureLoadingManager;

	typedef boost::function <void (TextureFrame*)> OnLoadedCallback;
	OnLoadedCallback callback;

	TextureFrame *texture;

	TextureLoadingNotifier(TextureFrame *texture, TextureLoadingNotifier::OnLoadedCallback callback): texture(texture), callback(callback) {}

public:
	static void AddTexture(TextureFrame *texture, OnLoadedCallback callback);

	void Invoke();
};


class TextureLoadingManager
{
	static TextureLoadingManager *instance;

	std::vector <TextureLoadingNotifier*> notifiers;

	TextureLoadingManager();

public:
	void LifeCycle();
	static TextureLoadingManager* GetInstance();

	void AddNotifier(TextureFrame *texture, TextureLoadingNotifier::OnLoadedCallback callback);
};

} // namespace material
} // namespace lib3d
} // namespace liba
using namespace liba;